import { useEffect, useState } from 'react'
import { getUserByPointsRank } from '../api/user.js'
import ScoreRankItem from './ScoreRankItem.jsx'
import {Card} from "antd"
function ScoreRank() {
  // 存储用户排名信息的
  const [userRankInfo, setUserRankInfo] = useState([])
  const getScorePankList = async () => {
    const res = await getUserByPointsRank()
    setUserRankInfo(res.data)
  }
  useEffect(() => {
    getScorePankList()
  }, [])
  let content = []
  for (let i = 0; i < userRankInfo.length; i++) {
    content.push(<ScoreRankItem rank={i + 1} key={userRankInfo[i]._id} userRankInfo={userRankInfo[i]} />)
  }
  return <Card title="积分排行榜">{content}</Card>
}

export default ScoreRank
